import { service, crudParamsSerializer } from '@/utils/request'
import { CreateQueryParams } from '@nestjsx/crud-request'
import { Post } from './post.dto'

const defaultPostData: Partial<Post> = {}

function getPosts (params?: CreateQueryParams) {
  return service.request({
    url: '/resources/posts',
    method: 'get',
    params,
    paramsSerializer: crudParamsSerializer
  })
}

function getPostById (id: number | string, params?: CreateQueryParams) {
  return service.request({
    url: `/resources/posts/${id}`,
    method: 'get',
    params,
    paramsSerializer: crudParamsSerializer
  })
}

export { defaultPostData, getPosts, getPostById }
